package com.example.myandtest;

import com.my.fragments.fgtest1;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class FragmenTabsTest extends FragmentActivity{

	private String[] imageUrls = {
			"http://www.baidu.com/img/baidu_jgylogo3.gif?v=98327836.gif",
			"http://pic.wenwen.soso.com/p/20120210/20120210201535-600429334.jpg",
			"http://pic1.win4000.com/pic/c/a6/80c4431006.jpg",
			"http://pic1.win4000.com/pic/c/a6/80c4431007.jpg"};
	 
	private fgtest1[] mFraglist;
	
	@Override
	protected void onCreate(Bundle arg0) 
	{
		super.onCreate(arg0);
		
		setContentView(R.layout.fragment_tabs_page);
		
		initViews();
	}
	
	private void initViews()
	{
		mFraglist = new fgtest1[4];
		for(int i=0;i<4;i++)
		{
			Bundle args = new Bundle();
			args.putString("url", imageUrls[i]);
			
			mFraglist[i] = new fgtest1();
			mFraglist[i].setArguments(args);
		}
		
		getSupportFragmentManager()
		.beginTransaction()
		.replace(R.id.container,mFraglist[0])
		.commit();
		
		Button bt1 = (Button)findViewById(R.id.button1);
		bt1.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) 
			{
				getSupportFragmentManager()
				.beginTransaction()
				.replace(R.id.container,mFraglist[0])
				.commit();
			}
		});
		
		Button bt4 = (Button)findViewById(R.id.button2);
		bt4.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) 
			{				
				getSupportFragmentManager()
				.beginTransaction()
				.replace(R.id.container,mFraglist[1])
				.commit();
			}
		});
		
		Button bt2 = (Button)findViewById(R.id.button3);
		bt2.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) 
			{
				getSupportFragmentManager()
				.beginTransaction()
				.replace(R.id.container,mFraglist[2])
				.commit();
				
			}
		});
		
		Button bt3 = (Button)findViewById(R.id.button4);
		bt3.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) 
			{
				getSupportFragmentManager()
				.beginTransaction()
				.replace(R.id.container,mFraglist[3])
				.commit();
				
			}
		});
	}
}
